﻿// <copyright file="ItemViewModel.cs" company="Microsoft Corporation">
// Copyright (c) 2009 Microsoft Corporation All Rights Reserved
// </copyright>
// <author>Michael S. Scherotter</author>
// <email>mischero@microsoft.com</email>
// <date>2010-08-20</date>
// <summary>ItemViewModel class definition</summary>

namespace WindowsPhoneListApplication
{
    using System;
    using System.ComponentModel;

    /// <summary>
    /// Item View Model
    /// </summary>
    public class ItemViewModel : INotifyPropertyChanged
    {
        #region Fields
        /// <summary>
        /// The first line
        /// </summary>
        private string lineOne;

        /// <summary>
        /// The second line
        /// </summary>
        private string lineTwo;

        /// <summary>
        /// The third line
        /// </summary>
        private string lineThree;
        #endregion

        #region Events
        /// <summary>
        /// Property change event handler
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;
        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets a Sample ViewModel property; this property is used in the view to display its value using a Binding.
        /// </summary>
        public string LineOne
        {
            get
            {
                return this.lineOne;
            }

            set
            {
                if (value != this.lineOne)
                {
                    this.lineOne = value;
                    this.NotifyPropertyChanged("LineOne");
                }
            }
        }

        /// <summary>
        /// Gets or sets a Sample ViewModel property; this property is used in the view to display its value using a Binding.
        /// </summary>
        /// <returns></returns>
        public string LineTwo
        {
            get
            {
                return this.lineTwo;
            }

            set
            {
                if (value != this.lineTwo)
                {
                    this.lineTwo = value;
                    this.NotifyPropertyChanged("LineTwo");
                }
            }
        }

        /// <summary>
        /// Gets or sets the Sample ViewModel property; this property is used in the view to display its value using a Binding.
        /// </summary>
        /// <returns></returns>
        public string LineThree
        {
            get
            {
                return this.lineThree;
            }

            set
            {
                if (value != this.lineThree)
                {
                    this.lineThree = value;
                    this.NotifyPropertyChanged("LineThree");
                }
            }
        }
        #endregion

        #region Implementation

        /// <summary>
        /// Notify that a property has changed
        /// </summary>
        /// <param name="propertyName">the property name</param>
        private void NotifyPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = this.PropertyChanged;

            if (null != handler)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        #endregion
    }
}